package workexp.alg.array;

import java.util.Random;

public class RandomeSolution {
    private int[] raw;

    public RandomeSolution(int[] nums) {
        this.raw=nums;
    }

    public int[] reset() {
        return raw;
    }

    public int[] shuffle() {
        if(this.raw==null){
            return null;
        }
        int[] result = raw.clone();
        Random random = new Random();
        for(int i =0 ;i<result.length;i++){
            int j = random.nextInt(result.length-i)+i;
            int tmp = result[i];
            result[i]=result[j];
            result[j]=tmp;
        }
        return result;
    }
}
